home *** CD-ROM | disk | FTP | other *** search
/ An Introduction to Progr…l Basic 6.0 (4th Edition) / An Introduction to Programming using Visual Basic 6.0.iso / PROGRAMS / CH4 / 4-3-3.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-09-18  |  2.9 KB  |  96 lines

  1. VERSION 5.00
  2. Begin VB.Form frm4_3_3 
  3.    Caption         =   "Right Triangle"
  4.    ClientHeight    =   2610
  5.    ClientLeft      =   1935
  6.    ClientTop       =   1740
  7.    ClientWidth     =   2475
  8.    BeginProperty Font 
  9.       Name            =   "MS Sans Serif"
  10.       Size            =   8.25
  11.       Charset         =   0
  12.       Weight          =   700
  13.       Underline       =   0   'False
  14.       Italic          =   0   'False
  15.       Strikethrough   =   0   'False
  16.    EndProperty
  17.    LinkTopic       =   "Form1"
  18.    PaletteMode     =   1  'UseZOrder
  19.    ScaleHeight     =   2610
  20.    ScaleWidth      =   2475
  21.    Begin VB.PictureBox picHyp 
  22.       Height          =   255
  23.       Left            =   1320
  24.       ScaleHeight     =   195
  25.       ScaleWidth      =   915
  26.       TabIndex        =   6
  27.       Top             =   2160
  28.       Width           =   975
  29.    End
  30.    Begin VB.CommandButton cmdCalculate 
  31.       Caption         =   "Calculate Hypotenuse"
  32.       Height          =   495
  33.       Left            =   240
  34.       TabIndex        =   4
  35.       Top             =   1320
  36.       Width           =   2055
  37.    End
  38.    Begin VB.TextBox txtSideTwo 
  39.       Height          =   285
  40.       Left            =   1320
  41.       TabIndex        =   3
  42.       Top             =   840
  43.       Width           =   975
  44.    End
  45.    Begin VB.TextBox txtSideOne 
  46.       Height          =   285
  47.       Left            =   1320
  48.       TabIndex        =   2
  49.       Top             =   240
  50.       Width           =   975
  51.    End
  52.    Begin VB.Label lblHyp 
  53.       Caption         =   "Length of hypotenuse"
  54.       Height          =   495
  55.       Left            =   240
  56.       TabIndex        =   5
  57.       Top             =   2040
  58.       Width           =   975
  59.    End
  60.    Begin VB.Label lblSideTwo 
  61.       Caption         =   "Length of other side"
  62.       Height          =   375
  63.       Left            =   240
  64.       TabIndex        =   1
  65.       Top             =   720
  66.       Width           =   975
  67.       WordWrap        =   -1  'True
  68.    End
  69.    Begin VB.Label lblSideOne 
  70.       Caption         =   "Length of one side"
  71.       Height          =   375
  72.       Left            =   240
  73.       TabIndex        =   0
  74.       Top             =   120
  75.       Width           =   975
  76.       WordWrap        =   -1  'True
  77.    End
  78. Attribute VB_Name = "frm4_3_3"
  79. Attribute VB_GlobalNameSpace = False
  80. Attribute VB_Creatable = False
  81. Attribute VB_PredeclaredId = True
  82. Attribute VB_Exposed = False
  83. Private Sub cmdCalculate_Click()
  84.   Dim a As Single, b As Single
  85.   'Calculate length of the hypotenuse of a right triangle
  86.   a = Val(txtSideOne.Text)
  87.   b = Val(txtSideTwo.Text)
  88.   picHyp.Cls
  89.   picHyp.Print Hypotenuse(a, b)
  90. End Sub
  91. Private Function Hypotenuse(a As Single, b As Single) As Single
  92.   'Calculate the hypotenuse of a right triangle
  93.   'having sides of lengths a and b
  94.   Hypotenuse = Sqr(a ^ 2 + b ^ 2)
  95. End Function
  96.